package com.leetcode.greedy;

/**
 * @author Dennis Li
 * @date 2020/7/21 22:44
 */
public class MaxProfit2_122 {

    public int maxProfit(int[] prices) {
        final int len = prices.length;
        int max = 0;
        for (int i = 1; i < len; i++) {
            if(prices[i] > prices[i - 1])
                max += prices[i] - prices[i - 1];
        }
        return max;
    }

}
